Option Explicit On 
Option Strict On

Public Class frmStdOrder
    Inherits System.Windows.Forms.Form
    Public Shared bUpdate As Boolean
    Public Shared oStdOrder As New StdOrderClass
    Friend WithEvents button_example As System.Windows.Forms.Button
    Private Shared cDigiFormIndex As New Collection

#Region " Windows Form Designer generated code "

    Public Sub New(ByVal inOrder As StdOrderClass)
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call
        oStdOrder = New StdOrderClass
        oStdOrder = inOrder

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Panel1 As System.Windows.Forms.Panel
    Friend WithEvents rdoAnalog As System.Windows.Forms.RadioButton
    Friend WithEvents rdoDigital As System.Windows.Forms.RadioButton
    Friend WithEvents pnlAnalog As System.Windows.Forms.Panel
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents txtAnalog As System.Windows.Forms.TextBox
    Friend WithEvents pnlDigital As System.Windows.Forms.Panel
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents lboxDigital As System.Windows.Forms.ListBox
    Friend WithEvents btnAddDigital As System.Windows.Forms.Button
    Friend WithEvents ToolTip1 As System.Windows.Forms.ToolTip
    Friend WithEvents btnEditDigital As System.Windows.Forms.Button
    Friend WithEvents btnDelDigital As System.Windows.Forms.Button
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents txtFees As System.Windows.Forms.TextBox
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents txtTurnaround As System.Windows.Forms.TextBox
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents btnOK As System.Windows.Forms.Button
    Friend WithEvents btnCancel As System.Windows.Forms.Button
    Friend WithEvents txtOrder As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmStdOrder))
        Me.Label1 = New System.Windows.Forms.Label
        Me.Panel1 = New System.Windows.Forms.Panel
        Me.rdoDigital = New System.Windows.Forms.RadioButton
        Me.rdoAnalog = New System.Windows.Forms.RadioButton
        Me.pnlAnalog = New System.Windows.Forms.Panel
        Me.txtAnalog = New System.Windows.Forms.TextBox
        Me.Label2 = New System.Windows.Forms.Label
        Me.pnlDigital = New System.Windows.Forms.Panel
        Me.btnDelDigital = New System.Windows.Forms.Button
        Me.btnEditDigital = New System.Windows.Forms.Button
        Me.btnAddDigital = New System.Windows.Forms.Button
        Me.lboxDigital = New System.Windows.Forms.ListBox
        Me.Label3 = New System.Windows.Forms.Label
        Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
        Me.txtFees = New System.Windows.Forms.TextBox
        Me.txtTurnaround = New System.Windows.Forms.TextBox
        Me.txtOrder = New System.Windows.Forms.TextBox
        Me.Label4 = New System.Windows.Forms.Label
        Me.Label5 = New System.Windows.Forms.Label
        Me.Label6 = New System.Windows.Forms.Label
        Me.btnOK = New System.Windows.Forms.Button
        Me.btnCancel = New System.Windows.Forms.Button
        Me.button_example = New System.Windows.Forms.Button
        Me.Panel1.SuspendLayout()
        Me.pnlAnalog.SuspendLayout()
        Me.pnlDigital.SuspendLayout()
        Me.SuspendLayout()
        '
        'Label1
        '
        Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label1.Location = New System.Drawing.Point(16, 17)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(56, 23)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "Format"
        '
        'Panel1
        '
        Me.Panel1.Controls.Add(Me.rdoDigital)
        Me.Panel1.Controls.Add(Me.rdoAnalog)
        Me.Panel1.Location = New System.Drawing.Point(64, 8)
        Me.Panel1.Name = "Panel1"
        Me.Panel1.Size = New System.Drawing.Size(168, 40)
        Me.Panel1.TabIndex = 1
        Me.Panel1.TabStop = True
        '
        'rdoDigital
        '
        Me.rdoDigital.Location = New System.Drawing.Point(96, 8)
        Me.rdoDigital.Name = "rdoDigital"
        Me.rdoDigital.Size = New System.Drawing.Size(64, 24)
        Me.rdoDigital.TabIndex = 1
        Me.rdoDigital.TabStop = True
        Me.rdoDigital.Text = "Digital"
        Me.ToolTip1.SetToolTip(Me.rdoDigital, "the description of options for obtaining the data set on computer-compatible medi" & _
                "a. ")
        '
        'rdoAnalog
        '
        Me.rdoAnalog.Location = New System.Drawing.Point(8, 8)
        Me.rdoAnalog.Name = "rdoAnalog"
        Me.rdoAnalog.Size = New System.Drawing.Size(80, 24)
        Me.rdoAnalog.TabIndex = 0
        Me.rdoAnalog.TabStop = True
        Me.rdoAnalog.Text = "Non-digital"
        Me.ToolTip1.SetToolTip(Me.rdoAnalog, "the description of options for obtaining the data set on non-computer-compatible " & _
                "media. ")
        '
        'pnlAnalog
        '
        Me.pnlAnalog.Controls.Add(Me.txtAnalog)
        Me.pnlAnalog.Controls.Add(Me.Label2)
        Me.pnlAnalog.Location = New System.Drawing.Point(309, 64)
        Me.pnlAnalog.Name = "pnlAnalog"
        Me.pnlAnalog.Size = New System.Drawing.Size(378, 138)
        Me.pnlAnalog.TabIndex = 2
        '
        'txtAnalog
        '
        Me.txtAnalog.AcceptsReturn = True
        Me.txtAnalog.Location = New System.Drawing.Point(8, 24)
        Me.txtAnalog.Multiline = True
        Me.txtAnalog.Name = "txtAnalog"
        Me.txtAnalog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
        Me.txtAnalog.Size = New System.Drawing.Size(360, 100)
        Me.txtAnalog.TabIndex = 1
        Me.ToolTip1.SetToolTip(Me.txtAnalog, "the description of options for obtaining the data set on non-computer-compatible " & _
                "media. ")
        '
        'Label2
        '
        Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label2.Location = New System.Drawing.Point(5, 8)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(100, 23)
        Me.Label2.TabIndex = 0
        Me.Label2.Text = "Non-digital Form"
        Me.ToolTip1.SetToolTip(Me.Label2, "the description of options for obtaining the data set on non-computer-compatible " & _
                "media. ")
        '
        'pnlDigital
        '
        Me.pnlDigital.Controls.Add(Me.btnDelDigital)
        Me.pnlDigital.Controls.Add(Me.btnEditDigital)
        Me.pnlDigital.Controls.Add(Me.btnAddDigital)
        Me.pnlDigital.Controls.Add(Me.lboxDigital)
        Me.pnlDigital.Controls.Add(Me.Label3)
        Me.pnlDigital.Location = New System.Drawing.Point(8, 64)
        Me.pnlDigital.Name = "pnlDigital"
        Me.pnlDigital.Size = New System.Drawing.Size(295, 105)
        Me.pnlDigital.TabIndex = 3
        '
        'btnDelDigital
        '
        Me.btnDelDigital.Enabled = False
        Me.btnDelDigital.Image = Global.MetaDoc.My.Resources.Resources.file_del_16x16
        Me.btnDelDigital.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.btnDelDigital.Location = New System.Drawing.Point(206, 69)
        Me.btnDelDigital.Name = "btnDelDigital"
        Me.btnDelDigital.Size = New System.Drawing.Size(75, 23)
        Me.btnDelDigital.TabIndex = 4
        Me.btnDelDigital.Text = "Delete"
        '
        'btnEditDigital
        '
        Me.btnEditDigital.Enabled = False
        Me.btnEditDigital.Image = Global.MetaDoc.My.Resources.Resources.file_edit_16x16
        Me.btnEditDigital.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.btnEditDigital.Location = New System.Drawing.Point(125, 69)
        Me.btnEditDigital.Name = "btnEditDigital"
        Me.btnEditDigital.Size = New System.Drawing.Size(75, 23)
        Me.btnEditDigital.TabIndex = 3
        Me.btnEditDigital.Text = "Edit"
        '
        'btnAddDigital
        '
        Me.btnAddDigital.Image = Global.MetaDoc.My.Resources.Resources.file_new_16x16
        Me.btnAddDigital.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.btnAddDigital.Location = New System.Drawing.Point(44, 69)
        Me.btnAddDigital.Name = "btnAddDigital"
        Me.btnAddDigital.Size = New System.Drawing.Size(75, 23)
        Me.btnAddDigital.TabIndex = 2
        Me.btnAddDigital.Text = "Add"
        '
        'lboxDigital
        '
        Me.lboxDigital.BorderStyle = System.Windows.Forms.BorderStyle.None
        Me.lboxDigital.Location = New System.Drawing.Point(11, 24)
        Me.lboxDigital.Name = "lboxDigital"
        Me.lboxDigital.Size = New System.Drawing.Size(270, 39)
        Me.lboxDigital.TabIndex = 1
        Me.ToolTip1.SetToolTip(Me.lboxDigital, "the description of options for obtaining the data set on computer-compatible medi" & _
                "a. ")
        '
        'Label3
        '
        Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label3.Location = New System.Drawing.Point(8, 8)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(88, 23)
        Me.Label3.TabIndex = 0
        Me.Label3.Text = "Digital Form"
        Me.ToolTip1.SetToolTip(Me.Label3, "the description of options for obtaining the data set on computer-compatible medi" & _
                "a. ")
        '
        'ToolTip1
        '
        Me.ToolTip1.IsBalloon = True
        Me.ToolTip1.ShowAlways = True
        Me.ToolTip1.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info
        '
        'txtFees
        '
        Me.txtFees.Location = New System.Drawing.Point(173, 208)
        Me.txtFees.Multiline = True
        Me.txtFees.Name = "txtFees"
        Me.txtFees.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
        Me.txtFees.Size = New System.Drawing.Size(450, 50)
        Me.txtFees.TabIndex = 5
        Me.ToolTip1.SetToolTip(Me.txtFees, "the fees and terms for retrieving the data set. ")
        '
        'txtTurnaround
        '
        Me.txtTurnaround.Location = New System.Drawing.Point(173, 264)
        Me.txtTurnaround.Multiline = True
        Me.txtTurnaround.Name = "txtTurnaround"
        Me.txtTurnaround.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
        Me.txtTurnaround.Size = New System.Drawing.Size(450, 50)
        Me.txtTurnaround.TabIndex = 7
        Me.ToolTip1.SetToolTip(Me.txtTurnaround, "typical turnaround time for the filling of an order. ")
        '
        'txtOrder
        '
        Me.txtOrder.Location = New System.Drawing.Point(173, 320)
        Me.txtOrder.Multiline = True
        Me.txtOrder.Name = "txtOrder"
        Me.txtOrder.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
        Me.txtOrder.Size = New System.Drawing.Size(450, 50)
        Me.txtOrder.TabIndex = 9
        Me.ToolTip1.SetToolTip(Me.txtOrder, "general instructions and advice about," & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "and special terms and services provided f" & _
                "or," & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "the data set by the distributor. ")
        '
        'Label4
        '
        Me.Label4.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label4.Location = New System.Drawing.Point(16, 211)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(56, 23)
        Me.Label4.TabIndex = 4
        Me.Label4.Text = "Fees"
        Me.ToolTip1.SetToolTip(Me.Label4, "the fees and terms for retrieving the data set. ")
        '
        'Label5
        '
        Me.Label5.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label5.Location = New System.Drawing.Point(16, 267)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(128, 24)
        Me.Label5.TabIndex = 6
        Me.Label5.Text = "Turnaround (optional)"
        Me.ToolTip1.SetToolTip(Me.Label5, "typical turnaround time for the filling of an order. ")
        '
        'Label6
        '
        Me.Label6.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label6.Location = New System.Drawing.Point(16, 323)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(176, 24)
        Me.Label6.TabIndex = 8
        Me.Label6.Text = "Ordering Instructions (optional)"
        Me.ToolTip1.SetToolTip(Me.Label6, "general instructions and advice about," & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "and special terms and services provided f" & _
                "or," & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "the data set by the distributor. ")
        '
        'btnOK
        '
        Me.btnOK.Enabled = False
        Me.btnOK.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.btnOK.Image = Global.MetaDoc.My.Resources.Resources.Ok_16x16
        Me.btnOK.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.btnOK.Location = New System.Drawing.Point(467, 376)
        Me.btnOK.Name = "btnOK"
        Me.btnOK.Size = New System.Drawing.Size(75, 23)
        Me.btnOK.TabIndex = 10
        Me.btnOK.Text = "OK"
        Me.btnOK.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'btnCancel
        '
        Me.btnCancel.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.btnCancel.Image = Global.MetaDoc.My.Resources.Resources.Cancel_16x16
        Me.btnCancel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.btnCancel.Location = New System.Drawing.Point(548, 376)
        Me.btnCancel.Name = "btnCancel"
        Me.btnCancel.Size = New System.Drawing.Size(75, 23)
        Me.btnCancel.TabIndex = 11
        Me.btnCancel.Text = "Cancel"
        Me.btnCancel.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'button_example
        '
        Me.button_example.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.button_example.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.button_example.Image = Global.MetaDoc.My.Resources.Resources.app_help_48x48
        Me.button_example.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.button_example.Location = New System.Drawing.Point(577, 12)
        Me.button_example.Name = "button_example"
        Me.button_example.Size = New System.Drawing.Size(110, 48)
        Me.button_example.TabIndex = 21
        Me.button_example.Text = "EXAMPLE"
        Me.button_example.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        Me.button_example.UseVisualStyleBackColor = True
        '
        'frmStdOrder
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(699, 407)
        Me.ControlBox = False
        Me.Controls.Add(Me.button_example)
        Me.Controls.Add(Me.btnCancel)
        Me.Controls.Add(Me.btnOK)
        Me.Controls.Add(Me.txtOrder)
        Me.Controls.Add(Me.Label6)
        Me.Controls.Add(Me.txtTurnaround)
        Me.Controls.Add(Me.Label5)
        Me.Controls.Add(Me.txtFees)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.pnlDigital)
        Me.Controls.Add(Me.pnlAnalog)
        Me.Controls.Add(Me.Panel1)
        Me.Controls.Add(Me.Label1)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.Name = "frmStdOrder"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Standard Order Process"
        Me.ToolTip1.SetToolTip(Me, "the common ways in which the data set may be obtained or received, and related in" & _
                "structions and fee information. ")
        Me.Panel1.ResumeLayout(False)
        Me.pnlAnalog.ResumeLayout(False)
        Me.pnlAnalog.PerformLayout()
        Me.pnlDigital.ResumeLayout(False)
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub

#End Region

    Private Sub frmStdOrder_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim s1 As String = ""
        Dim indexVal As Integer = 0
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim oDigiForm As New DigitalOrderClass
        bUpdate = False
        cDigiFormIndex = New Collection
        rdoAnalog.Checked = False
        rdoDigital.Checked = False
        lboxDigital.Items.Clear()
        pnlDigital.Enabled = False
        txtAnalog.Text = ""
        pnlAnalog.Enabled = False
        txtFees.Text = ""
        txtOrder.Text = ""
        txtTurnaround.Text = ""

        cDigiFormIndex = oStdOrder.DigitalForms 'collection of index values linking to frmMetaMain.cDigitalForm
        iCount = cDigiFormIndex.Count
        If (oStdOrder.NonDigitalForm <> "") Then
            'this is an analog order process
            rdoAnalog.Checked = True
            Panel1.Enabled = False 'cannot change type
            pnlAnalog.Enabled = True
            With oStdOrder
                txtAnalog.Text = .NonDigitalForm
                txtFees.Text = .Fees
                txtOrder.Text = .Instructions
                txtTurnaround.Text = .Turnaround
            End With
        ElseIf (iCount > 0) Then
            'this is a digital order process
            rdoDigital.Checked = True
            Panel1.Enabled = False 'cannot change type
            pnlDigital.Enabled = True
            'populate the digital form list box
            For iLoop = 1 To iCount
                indexVal = CType(cDigiFormIndex(iLoop), Integer) 'retrieve the index value from collection
                oDigiForm = CType(frmMain.f61.cDigitalForm(indexVal), DigitalOrderClass) 'local copy of digital form
                s1 = "Digital format: " & oDigiForm.FormatName
                lboxDigital.Items.Add(s1) 'add format descriptor to list box
            Next
            With oStdOrder
                txtFees.Text = .Fees
                txtOrder.Text = .Instructions
                txtTurnaround.Text = .Turnaround
            End With
        Else
            'do nothing; new order process
        End If
    End Sub

    Private Sub rdoAnalog_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdoAnalog.CheckedChanged
        'Panel1.Enabled = False 'user cannot change type once selected
        pnlDigital.Enabled = False
        pnlAnalog.Enabled = True 'enable appropriate input panel
        'txtAnalog.Focus()
        checkOK()
    End Sub

    Private Sub rdoDigital_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdoDigital.CheckedChanged
        'Panel1.Enabled = False 'user cannot change type once selected
        pnlAnalog.Enabled = False
        pnlDigital.Enabled = True 'enable appropriate input panel
        'btnAddDigital.Focus()
        checkOK()
    End Sub

    Private Sub btnAddDigital_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddDigital.Click
        Dim s1 As String = ""
        Dim indexVal As Integer = 0 '0 or negative = new Digital Form
        Dim newDigiForm As New frmDigitalForm(indexVal)
        newDigiForm.ShowDialog()
        If (newDigiForm.getUpdated() = True) Then
            frmMain.f61.cDigitalForm.Add(newDigiForm.getDigiForm()) 'add new Digital Form to collection
            indexVal = frmMain.f61.cDigitalForm.Count 'get updated count of Forms = last index value
            cDigiFormIndex.Add(indexVal) 'add index value to index value collection
            s1 = "Digital format: " & newDigiForm.getDigiForm().FormatName
            lboxDigital.Items.Add(s1) 'add format descriptor to list box
        End If
        checkOK()
    End Sub

    Private Sub btnEditDigital_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEditDigital.Click
        Dim s1 As String = ""
        Dim iVal As Integer = lboxDigital.SelectedIndex
        Dim iCount As Integer = lboxDigital.Items.Count
        If (iVal = -1) Then
            If (iCount = 0) Then
                s1 = "No Digital Form available for editing"
                MessageBox.Show(s1, "Selection error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return
            ElseIf (iCount = 1) Then
                iVal = 0 'if only 1 entry, assume user wants to edit it
            Else
                s1 = "No Digital Form selected for editing"
                MessageBox.Show(s1, "Selection error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return
            End If
        End If

        iCount = CType(cDigiFormIndex(iVal + 1), Integer) 'retrieve index value after correcting to 1-based index
        Dim editDigiForm As New frmDigitalForm(iCount) 'create new form; pass index corresponding to main collection
        editDigiForm.ShowDialog()
        If (editDigiForm.getUpdated() = True) Then
            frmMain.f61.cDigitalForm.Add(editDigiForm.getDigiForm(), , iCount) 'insert edited Digital Form into collection
            frmMain.f61.cDigitalForm.Remove(iCount + 1) 'remove old version; 1-based collection
            'cDigiFormIndex does not need to be updated; still points to the right place
            s1 = "Digital format: " & editDigiForm.getDigiForm().FormatName
            lboxDigital.Items.Insert(iVal, s1) 'insert edited format descriptor into list box
            lboxDigital.Items.RemoveAt(iVal + 1) '0-based collection
        End If
        btnEditDigital.Enabled = False : btnDelDigital.Enabled = False
        checkOK()
    End Sub

    Private Sub btnDelDigital_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelDigital.Click
        Dim s1 As String = ""
        Dim iVal As Integer = lboxDigital.SelectedIndex
        If (iVal = -1) Then
            s1 = "No Digital Form selected for deletion"
            MessageBox.Show(s1, "Selection error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Return
        Else
            cDigiFormIndex.Remove(iVal + 1) '1-based collection
            lboxDigital.Items.RemoveAt(iVal) '0-based collection
            'notice that we have NOT removed any items from the main cDigitalForm collection
            'this maintains the coherence of all the other index collections without additional updating
        End If
        btnEditDigital.Enabled = False : btnDelDigital.Enabled = False
        checkOK()
    End Sub

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        Dim s1 As String = ""
        Dim iCount As Integer = 0
        If (rdoAnalog.Checked = False And rdoDigital.Checked = False) Then
            s1 = "Must select analog or digital format."
            MessageBox.Show(s1, "Insufficient information", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Return
        End If
        If (txtFees.Text = "") Then
            s1 = "Fees information is required."
            MessageBox.Show(s1, "Insufficient information", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Return
        End If
        If (rdoAnalog.Checked = True) Then
            If (txtAnalog.Text = "") Then
                s1 = "Non-digital Form is required."
                MessageBox.Show(s1, "Insufficient information", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return
            Else
                With oStdOrder
                    .NonDigitalForm = txtAnalog.Text
                    .Fees = txtFees.Text
                    .Instructions = txtOrder.Text
                    .Turnaround = txtTurnaround.Text
                End With
                bUpdate = True
                Me.Close()
            End If
        End If
        If (rdoDigital.Checked = True) Then
            iCount = cDigiFormIndex.Count 'retrieve current count of index entries
            If (iCount = 0) Then
                s1 = "At least 1 Digital Form is required."
                MessageBox.Show(s1, "Insufficient information", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return
            Else
                With oStdOrder
                    .DigitalForms = cDigiFormIndex
                    .Fees = txtFees.Text
                    .Instructions = txtOrder.Text
                    .Turnaround = txtTurnaround.Text
                End With
                bUpdate = True
                Me.Close()
            End If
        End If
    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        bUpdate = False
        Me.Close()
    End Sub

    Public Function getUpdated() As Boolean
        Return bUpdate
    End Function
    Public Function getStdOrder() As StdOrderClass
        Return oStdOrder
    End Function

    Private Sub txtFees_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtFees.TextChanged
        checkOK()
    End Sub
    Private Sub checkOK()
        If txtFees.Text.Trim() = "" Or (rdoAnalog.Checked And txtAnalog.Text.Trim() = "") Or (rdoDigital.Checked And lboxDigital.Items.Count() = 0) Then btnOK.Enabled = False Else btnOK.Enabled = True
    End Sub

    Private Sub txtAnalog_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtAnalog.TextChanged
        checkOK()
    End Sub

    Private Sub lboxDigital_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lboxDigital.SelectedIndexChanged
        If lboxDigital.SelectedItems.Count() > 0 Then btnEditDigital.Enabled = True : btnDelDigital.Enabled = True Else btnEditDigital.Enabled = False : btnDelDigital.Enabled = False
    End Sub

    Private Sub button_example_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button_example.Click
        Dim helpForm As dialog_help = New dialog_help("StdOrder")
        helpForm.ShowDialog()
    End Sub
End Class
